package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.common.annotation.LoginUser;
import com.ibeeking.found.common.entity.CurrentUser;
import com.ibeeking.found.msg.rest.service.IWxMpMsgService;
import com.ibeeking.found.msg.service.common.param.WxMpMsgParam;
import com.ibeeking.found.msg.service.common.query.WxMpMsgPageQuery;
import com.ibeeking.found.msg.service.common.vo.WxMpMsgVO;
import com.ibeeking.found.msg.service.common.vo.WxMpGroupMessageUploadVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;

import lombok.extern.slf4j.Slf4j;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

//来源JL
@Slf4j
@RestController
@RequestMapping("/b/wxMp/msg/v1")
public class WxMpMsgController {


    @Resource
    private IWxMpMsgService wxMpMsgServiceImpl;

    /**
    * 分页查询
    * @param pageQuery 微信消息
    * @return
    */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "消息推送分页查询")
    @PostMapping("/pageList")
    public Object pageList(@ModelAttribute WxMpMsgPageQuery pageQuery) {
		return this.wxMpMsgServiceImpl.pageList(pageQuery);
    }

    /**
    * 通过id查询微信消息
    * @param id id
    * @return R
    */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "通过id查询微信消息")
    @PostMapping("/view/{id}")
    public WxMpGroupMessageUploadVO.Message view(@PathVariable("id") Long id){
    	return  wxMpMsgServiceImpl.view(id);
    }

    /**
    * 新增微信消息
    * @param param 微信消息
    * @return R
    */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "新增微信消息")
    @PostMapping("/add")
    public WxMpMsgVO add(@RequestBody @Validated(BaseValidationGroup.Insert.class) WxMpMsgParam param){
        return this.wxMpMsgServiceImpl.add(param);
    }

    /**
    * 修改微信消息
    * @param param 微信消息
    * @return R
    */
    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改微信消息")
    @PostMapping("/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) WxMpMsgParam param){
        return wxMpMsgServiceImpl.modify(param);
    }

    /**
    * 通过id删除微信消息
    * @param id id
    * @return R
    */
    @Log(logType = OperateLogTypeEnum.DEL, describe = "通过id删除微信消息")
    @PostMapping("/del/{id}")
    public Object del(@PathVariable("id") Long id){
    	return  wxMpMsgServiceImpl.del(id);
    }

}
